package ru.maxmatveev.dyndao;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;

/**
 * Pagination parameter for DAO methods.
 * @author Max Matveev
 *         Date: Dec 21, 2008
 *         Time: 3:15:35 PM
 */
public class Pagination {
    /** Field firstResult  */
    private int firstResult;
    /** Field maxResults  */
    private int maxResults;

    /**
     * Constructor, takes "from" row number and maximum count of rows to return.
     * @param firstResult first desired row number
     * @param maxResults maximum count of rows to return
     */
    public Pagination(int firstResult, int maxResults) {
        this.firstResult = firstResult;
        this.maxResults = maxResults;
    }

    /**
     * Get first row number.
     * @return first row number
     */
    public int getFirstResult() {
        return firstResult;
    }

    /**
     * Get maximum number of rows desired.
     * @return maximum number of rows
     */
    public int getMaxResults() {
        return maxResults;
    }

    /**
     * Use pagination.
     *
     * @author cthulhu
     * Created on Dec 29, 2008
     */
    @Retention(RetentionPolicy.RUNTIME)
    @Target(ElementType.PARAMETER)
    public @interface Paginate {
    }
}
